package vistas;

import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.swing.DefaultComboBoxModel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JLabel;

import clases.ActualizaGestor_class;
import clases.Historial_class;

public class COBROS_actualizarGestor extends JDialog {

	/**
	 * Launch the application.
	 */
	
	
	private JComboBox gestorActualizacion;
	
	
	
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					COBROS_actualizarGestor dialog = new COBROS_actualizarGestor("","");
					dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
					dialog.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the dialog.
	 */
	public COBROS_actualizarGestor(final String codigocliente, final String codigogestor) {
		setTitle("Actualizar a Gestor");
		setBounds(100, 100, 349, 76);
		getContentPane().setLayout(null);
		
		
		/**/
		
		final SimpleDateFormat sdfFecha = new SimpleDateFormat("yyyy-MM-dd");
		final SimpleDateFormat sdfHora = new SimpleDateFormat("HH:mm:ss");
		final SimpleDateFormat sdfAMP = new SimpleDateFormat("aa");
		final SimpleDateFormat formatRec = new SimpleDateFormat("yyyyMMdd");
		final  String fechaRec = formatRec.format(new Date());
		
		/**/
		
		JLabel label = new JLabel();
		label.setText("Gestor");
		label.setFont(new Font("Arial", Font.PLAIN, 12));
		label.setBounds(10, 11, 37, 15);
		getContentPane().add(label);
		
		gestorActualizacion = new JComboBox();
		gestorActualizacion.setModel(new DefaultComboBoxModel(new String[] {"ahenriquez", "gmonge", "gsevillano", "jflores", "khenriquez", "lgarcia", "opadilla", "spalma", "wmorales"}));
		gestorActualizacion.setSelectedIndex(-1);
		gestorActualizacion.setBounds(61, 9, 126, 20);
		getContentPane().add(gestorActualizacion);
		
		JButton button = new JButton("Guardar");
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				if (gestorActualizacion.getSelectedIndex() != -1) {
					new Historial_class(codigocliente, new Date(), new Date(), new Date(), "Actualizacion de Datos del Cliente en Sistema", "Actualizacion", "Actualizacion", "1", "0", codigogestor, "").insertar();

	                if (!gestorActualizacion.getSelectedItem().toString().trim().equals(codigogestor)) {
	                    new ActualizaGestor_class(codigocliente, codigogestor, gestorActualizacion.getSelectedItem().toString()).insertar();
	                }
	            }
			}
		});
		button.setIcon(new ImageIcon(COBROS_actualizarGestor.class.getResource("/images/guardar.png")));
		button.setToolTipText("(Ctrl+G)");
		button.setForeground(Color.BLACK);
		button.setFont(new Font("Arial", Font.PLAIN, 13));
		button.setBounds(197, 8, 109, 23);
		getContentPane().add(button);

	}
}
